package com.ludomancy.gamelib;

import java.awt.Color;
import java.awt.Graphics;

public class BarPainter
{
    public static void paint(Graphics g, Color backgroundColor, Color valueColor, int x, int y, int width, int height, int value, int max)
    {
        // limit values
        if(value < 0)
        {
            value = 0;
        }
        if(value > max)
        {
            value = max;
        }
        // figure out the limits
        int finalWidth = value*width/max;
        g.setColor(backgroundColor);
        g.fillRect(x,y,finalWidth,height);
        g.setColor(valueColor);
        g.fillRect(x+1,y+1,finalWidth-2,height-2);
    }
}
